// 源插件
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import moment from 'moment';
import router from 'umi/router';
import { NumberDivide, DateDiff, FormatnumberZero, Mover, DateStamp } from '@/function.js';

// 视图插件
import {
  BackTop,
  Empty,
  Spin,
  Row,
  Col,
  Card,
  Form,
  Input,
  Select,
  Icon,
  Button,
  Dropdown,
  Menu,
  InputNumber,
  DatePicker,
  Modal,
  message,
  Badge,
  Divider,
  Steps,
  Radio,
  Upload,
  Checkbox,
} from 'antd';
import TimelineChartSeven from '@/components/Charts/TimelineChartSeven';

// 外部组件
import StandardTable from '@/components/StandardTable';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import Loading from '@/components/Loading/Loading';
import ReactKline from 'react-kline-pro';

// css OR less预编译器
import $ from 'jquery';

// 图片

// 计算
import _pull from 'lodash/pull';
import _indexOf from 'lodash/indexOf';
import KlineEchartsNewTwo from '../../../components/KlineEcharts/KlineEchartsNewTwo';
import styles from './All.less';

/**
 *  Describe:数据连接
 *  Created by xjc on 2019/5/15
 */

@connect(({ fu, loading }) => ({
  fu,
  loading: loading.models.fuRule,
}))
@Form.create()
class NewTwoPosition extends PureComponent {
  componentWillMount() {}

  /**
   *  Describe:当前状态
   *  Created by xjc on 2019/5/15
   */

  state = {
    listLoading: false, // 加载状态
    selectedRows: [], // 选择行
    formValues: {
      num: 10,
      page: 1,
    }, // 表格参数
    /* pageValues:{current: 1, pageSize: 10, total: 0}, */
    kVisible: false, // modal开关
    tVisible: false, // modal开关
    eVisible: false, // modal开关
    symbol: 'US.BABA',
    record: {}, // 当前行内容
    searchText: '', // 搜索内容
    columns: [], // 表头处理结果
    currentDataSource: [], // 表剩余数据
    chart: {},
    codes: '',
    checkbox: [
      '股票代码',
      '涨跌幅',
      '涨跌幅/BETA',
      '盈利百分比',
      '前一日放量系数',
      'ATR',
      '股票敞口%',
      '市值',
      '成本价',
      '最新价',
      '持仓股数',
      'AQ',
      'DQ',
      '实值SP',
      '实值SC',
      '剩余数量',
      '当日盈亏',
      '剩余数量当日盈亏',
      '盈亏金额',
      '同行',
      '剩余市值/(万)',
    ],
    update: false,
  };

  /**
   *  Describe:本地搜索
   *  Created by xjc on 2019/6/4
   */

  getColumnSearchProps = dataIndex => ({
    filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
      <div style={{ padding: 8 }}>
        <Input
          ref={node => {
            this.searchInput = node;
          }}
          placeholder={`Search ${dataIndex}`}
          value={selectedKeys[0]}
          onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
          onPressEnter={() => this.handleSearch(selectedKeys, confirm)}
          style={{ width: 188, marginBottom: 8, display: 'block' }}
        />
        <Button
          type="primary"
          onClick={() => this.handleSearch(selectedKeys, confirm)}
          icon="search"
          size="small"
          style={{ width: 80, marginRight: 8 }}
        >
          搜索
        </Button>
        <Button onClick={() => this.handleReset(clearFilters)} size="small" style={{ width: 80 }}>
          重置
        </Button>
      </div>
    ),
    filterIcon: filtered => (
      <Icon type="search" style={{ color: filtered ? '#1880ff' : '#181816', fontWeight: '700' }} />
    ),
    onFilter: (value, record) => {
      if (record[dataIndex] === '股票合计') {
        return true;
      }
      return record[dataIndex] === null
        ? ''
        : record[dataIndex]
            .toString()
            .toLowerCase()
            .includes(value.toLowerCase());
    },
    onFilterDropdownVisibleChange: visible => {
      if (visible) {
        setTimeout(() => this.searchInput.select());
      }
    },
    render: text => <span>{text}</span>,
  });

  handleSearch = (selectedKeys, confirm) => {
    confirm();
    this.setState({ searchText: selectedKeys[0] });
  };

  handleReset = clearFilters => {
    clearFilters();
    this.setState({ searchText: '' });
  };

  klineModalOpen(value) {
    const that = this;

    // router.push('/Kline/Kline/:'+value)
    $.ajax({
      type: 'GET',
      url: `http://fss.91stock.net/fss/Kline/GetStockInfo?code=${value}`,
      contentType: 'application/x-www-form-urlencoded;charset=utf-8',
      dataType: 'json',
      async: false,
      success(data) {
        if (data.myCode !== null) {
          const { dispatch } = that.props;
          dispatch({
            type: 'fu/GetStockRunPoint',
            payload: data.myCode,
            callback: res => {
              that.setState({
                codes: res.codes,
                chart: res.list,
                kVisible: true,
                symbol: data.myCode,
              });
            },
          });
          /* that.setState({ Visible: true }); */
        } else {
          message.error('暂无该股票信息');
        }
      },
      error(e) {
        console.log(e);
      },
    });

    // this.setState({ Visible: true }, () => {       this.setState({ symbol: value });     });
  }

  klineModalClose() {
    this.setState({ kVisible: false });
  }

  TimelineModalClose() {
    this.setState({ tVisible: false });
  }

  eModalClose() {
    this.setState({ eVisible: false });
  }

  check(param) {
    const that = this;
    const { checkbox } = this.state;
    if (_indexOf(checkbox, param) !== -1) {
      that.setState(
        {
          checkbox: _pull(checkbox, param),
          update: true,
        },
        () => {
          that.getColumns();
        }
      );
    } else {
      checkbox.push(param);
      that.setState(
        {
          checkbox,
          update: true,
        },
        () => {
          that.getColumns();
        }
      );
    }
  }

  getColumns() {
    const { checkbox } = this.state;
    const columns = [
      /* {
            title: '序号',
            dataIndex: 'p',
          }, */
      {
        title: '股票代码',
        dataIndex: 'mystock',
        width: 110,
        align: 'center',
        sorter: (a, b) => {
          const c = [a.mystock, b.mystock].sort();
          if (c[0] === a.mystock) {
            return 1;
          }
          return -1;
        },
        ...this.getColumnSearchProps('mystock'),
        render: (value, row, index) => {
          return (
            <span style={{ cursor: 'pointer' }} onClick={this.klineModalOpen.bind(this, value)}>
              {value}
            </span>
          );
        },
      },
      {
        title: '涨跌幅',
        dataIndex: 'gain',
        align: 'center',
        width: 90,
        sorter: (a, b) => a.gain - b.gain,
        render: (value, row, index) => {
          return (
            <span style={{ color: value > 0 ? '#389e0d' : '#e1111e' }}>
              {typeof value === 'number' || typeof value === 'string'
                ? `${FormatnumberZero(value, 2).toString()}%`
                : null}
            </span>
          );
        },
        onCell: record => ({
          className: styles.newFunction,
        }),
      },
      {
        title: '涨跌幅/BETA',
        dataIndex: 'gainbeta',
        align: 'center',
        width: 90,
        sorter: (a, b) => a.gainbeta - b.gainbeta,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? FormatnumberZero(value, 2).toString()
                : null}
            </span>
          );
        },
        className: styles.newFunction,
      },
      {
        title: '盈利百分比',
        dataIndex: 'incomepercent',
        align: 'center',
        width: 90,
        sorter: (a, b) => a.incomepercent - b.incomepercent,
        render: (value, row, index) => {
          return <span>{NumberDivide(value, 2, '%')}</span>;
        },
        className: styles.newFunction,
      },
      {
        title: '前一日放量系数',
        dataIndex: 'x1',
        align: 'center',
        width: 90,
        sorter: (a, b) => a.x1 - b.x1,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(FormatnumberZero(value, 4).toString())
                : null}
            </span>
          );
        },
        className: styles.newFunction,
      },
      {
        title: '日均50放量系数',
        dataIndex: 'x2',
        align: 'center',
        width: 90,
        sorter: (a, b) => a.x2 - b.x2,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(FormatnumberZero(value, 4).toString())
                : null}
            </span>
          );
        },
        className: styles.newFunction,
      },
      {
        title: 'ATR',
        dataIndex: 'atr',
        align: 'center',
        width: 80,
        sorter: (a, b) => a.atr - b.atr,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(FormatnumberZero(value, 2).toString())
                : null}
            </span>
          );
        },
        className: styles.newFunction,
      },
      /*  {
          title: '买卖方向',
          dataIndex: 'typename',
          width:80,
          align: 'center',
          filters: [
            {
              text: '多头',
              value: "多头",
            },
            {
              text: '空头',
              value: "空头",
            },
          ],
          onFilter: (value, record) => {
            if(record.mystock==='股票合计'){
              return true;
            }else {
              if (record.typename!==undefined){
                return record.typename.indexOf(value) === 0
              }
            }
          },
        }, */
      {
        title: '股票敞口%',
        dataIndex: 'stockopen',
        align: 'center',
        width: 80,
        sorter: (a, b) => a.stockopen - b.stockopen,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? `${NumberDivide((value * 100).toFixed(2).toString())}%`
                : null}
            </span>
          );
        },
      },
      {
        title: '市值',
        dataIndex: 'costmoney',
        align: 'center',
        width: 100,
        sorter: (a, b) => a.costmoney - b.costmoney,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '成本价',
        width: 80,
        dataIndex: 'costprice',
        align: 'center',
        sorter: (a, b) => a.costprice - b.costprice,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '最新价',
        width: 80,
        dataIndex: 'stockprice',
        align: 'center',
        sorter: (a, b) => a.stockprice - b.stockprice,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '持仓股数',
        dataIndex: 'stocknumber',
        align: 'center',
        width: 80,
        sorter: (a, b) => a.stocknumber - b.stocknumber,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: 'AQ',
        dataIndex: 'aqnum',
        width: 80,
        type: 'number',
        sorter: true,
      },
      {
        title: 'DQ',
        dataIndex: 'dqnum',
        width: 80,
        type: 'number',
        sorter: true,
      },
      {
        title: '实值SP',
        dataIndex: 'realSp',
        width: 80,
        type: 'number',
        sorter: true,
      },
      {
        title: '实值SC',
        dataIndex: 'realSc',
        width: 80,
        type: 'number',
        sorter: true,
      },
      {
        title: '剩余市值/(万)',
        dataIndex: 'lastMarketValue',
        width: 80,
        type: 'number',
        sorter: true,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' ? NumberDivide(mathService.div(value, 10000), 2) : null}
            </span>
          );
        },
      },
      {
        title: '剩余数量',
        dataIndex: 'lastNum',
        align: 'center',
        width: 100,
        sorter: (a, b) => a.lastNum - b.lastNum,
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '当日盈亏',
        dataIndex: 'thisincome',
        align: 'center',
        width: 100,
        sorter: (a, b) => {
          if (b.mystock === '股票合计') {
            return false;
          }
          return a.thisincome - b.thisincome;
        },
        render: (tags, record) => {
          if (record.mystock === '股票合计') {
            return (
              <span>
                {typeof tags === 'number' || typeof tags === 'string'
                  ? `${NumberDivide(tags.toString())}/${(
                      (tags / (record.costmoney - tags)) *
                      100
                    ).toFixed(2)}%`
                  : null}
                {}
              </span>
            );
          }
          return (
            <span>
              {typeof tags === 'number' || typeof tags === 'string'
                ? NumberDivide(tags.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '剩余数量当日盈亏',
        dataIndex: 'lastNumThisIncome',
        align: 'center',
        width: 100,
        sorter: (a, b) => {
          if (b.mystock === '股票合计') {
            return false;
          }
          return a.lastNumThisIncome - b.lastNumThisIncome;
        },
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '盈亏金额',
        dataIndex: 'allincome',
        width: 100,
        align: 'center',
        sorter: (a, b) => {
          if (b.mystock === '股票合计') {
            return false;
          }
          return a.allincome - b.allincome;
        },
        render: (value, row, index) => {
          return (
            <span>
              {typeof value === 'number' || typeof value === 'string'
                ? NumberDivide(value.toString())
                : null}
            </span>
          );
        },
      },
      {
        title: '同行',
        dataIndex: 'industryinfolist',
        align: 'center',
        width: 120,
        render: (value, row, index) => {
          if (value !== null && typeof value === 'object') {
            const arr = [];
            for (let i = 0; i < value.length; i++) {
              arr[i] = (
                <div
                  style={{ cursor: 'pointer' }}
                  onClick={this.klineModalOpen.bind(this, value[i].stock)}
                >
                  {`${value[i].stock} (`}
                  <span style={{ color: value[i].gain > 0 ? '#389e0d' : '#e1111e' }}>
                    {`${value[i].gain}%`}
                  </span>
                  )
                </div>
              );
            }
            return <div>{arr}</div>;
          }
          return null;
        },
        className: styles.newFunction,
      },
    ];
    for (let i = 0; i < columns.length; i++) {
      const item = columns[i];
      if (_indexOf(checkbox, item.title) === -1) {
        columns.splice(i, 1);
        i--;
      }
    }
    this.setState({
      update: false,
    });
    return columns;
  }

  handleStandardTableChange = (pagination, filtersArg, sorter, extra) => {
    const { dispatch } = this.props;
    const { formValues } = this.state;
    this.setState({
      currentDataSource: extra.currentDataSource,
    });
  };

  onRequestData(param, callback) {
    const that = this;
    $.ajax({
      type: 'GET',
      url: `http://fss.91stock.net/fss/Kline/GetKline?code=${param.symbol}`,
      contentType: 'application/x-www-form-urlencoded;charset=utf-8',
      dataType: 'json',
      async: true,
      success(data) {
        if (data.code === 1) {
          let dataCall = [];
          const coordinates = [];
          // debugger
          coordinates[0] = data.coordinates[data.coordinates.length - 1];
          dataCall = data.kline.data.item;
          callback({
            success: true,
            data: {
              lines: dataCall,
              monthCoordinates: data.monthCoordinates,
              coordinates,
              symbol: data.kline.data.symbol,
            },
          });
        }
      },
      error(e) {
        console.log(e);
      },
    });
  }

  /**
   *  Describe:视图
   *  Created by xjc on 2019/5/15
   */

  render() {
    const {
      loading,
      fu: { newTwoStocks },
    } = this.props;
    const {
      listLoading,
      selectedRows,
      kVisible,
      tVisible,
      symbol,
      chart,
      codes,
      ifKline,
      eVisible,
      update,
    } = this.state;
    let columns = [];
    const stocksList = [];
    if (columns.length === 0 && newTwoStocks.code === 1) {
      columns = this.getColumns();
    }
    return (
      <PageHeaderWrapper title="傅总股票持仓">
        <Card>
          {/* <Row> */}
          <Checkbox
            onChange={this.check.bind(this, '股票代码')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            股票代码
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '涨跌幅')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            涨跌幅
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '涨跌幅/BETA')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            涨跌幅/BETA
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '盈利百分比')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            盈利百分比
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '前一日放量系数')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            前一日放量系数
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '日均50放量系数')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            日均50放量系数
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, 'ATR')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            ATR
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '股票敞口%')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            股票敞口%
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '市值')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            市值
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '成本价')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            成本价
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '最新价')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            最新价
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '持仓股数')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            持仓股数
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, 'AQ')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            AQ
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, 'DQ')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            DQ
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '实值SP')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            实值SP
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '实值SC')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            实值SC
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '剩余数量')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            剩余数量
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '剩余市值/(万)')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            剩余市值/(万)
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '当日盈亏')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            当日盈亏
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '剩余数量当日盈亏')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            剩余数量当日盈亏
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '盈亏金额')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            盈亏金额
          </Checkbox>
          <Checkbox
            onChange={this.check.bind(this, '同行')}
            className={styles['ant-checkbox-wrapper']}
            defaultChecked
          >
            同行
          </Checkbox>
          {/* </Row> */}
          {newTwoStocks.code === 0 || update ? (
            <Loading />
          ) : (
            <div>
              <div style={{ margin: 8, fontSize: '1rem' }}>
                共计：{this.state.currentDataSource.length - 1}
              </div>
              <StandardTable
                bordered
                selectedRows={selectedRows}
                loading={listLoading}
                data={newTwoStocks}
                columns={columns}
                style={{ tableLayout: 'fixed' }}
                className={styles.TableLayout}
                pagination={false}
                onChange={this.handleStandardTableChange}
                scroll={{ x: 1400, y: 628 }}
                rowClassName={(record, index) =>
                  record.mystock === '股票合计' ? styles.statisticssTableBackground : styles.ffffff
                }
                // rowKey="id"
              />
            </div>
          )}
        </Card>
        <Modal
          width="90%"
          title={codes}
          footer=""
          // destroyOnClose={true}
          visible={kVisible}
          centered
          onOk={this.klineModalClose.bind(this)}
          onCancel={this.klineModalClose.bind(this)}
        >
          <div style={{ textAlign: 'left' }}>
            <Button
              type=""
              onClick={() => {
                this.setState({ kVisible: false, tVisible: true });
              }}
              style={{ marginRight: 30 }}
            >
              {'切换到跑分系统'}
            </Button>
            <Button
              type=""
              onClick={() => {
                this.setState({ eVisible: true, kVisible: false });
              }}
            >
              {'切换到相对强度'}
            </Button>
          </div>
          <br />
          <ReactKline
            // width={900}
            // height={400}
            height={688}
            ranges={['1d']}
            symbol={symbol}
            symbolName={symbol}
            intervalTime={500000000}
            depthWidth={100}
            // debug={true}
            onRequestData={this.onRequestData.bind(this)}
          />
        </Modal>

        <Modal
          width="90%"
          title={codes}
          footer=""
          // destroyOnClose={true}
          visible={tVisible}
          centered
          onOk={this.TimelineModalClose.bind(this)}
          onCancel={this.TimelineModalClose.bind(this)}
        >
          <div style={{ textAlign: 'left' }}>
            <Button
              type=""
              onClick={() => {
                this.setState({ kVisible: true, tVisible: false });
              }}
              style={{ marginRight: 30 }}
            >
              {'切换到k线系统'}
            </Button>
            <Button
              type=""
              onClick={() => {
                this.setState({ eVisible: true, tVisible: false });
              }}
            >
              {'切换到相对强度'}
            </Button>
          </div>
          <TimelineChartSeven height={document.body.clientHeight * 0.8} data={chart} />
        </Modal>

        <Modal
          width="90%"
          title={codes}
          footer=""
          destroyOnClose
          visible={eVisible}
          centered
          onOk={this.eModalClose.bind(this)}
          onCancel={this.eModalClose.bind(this)}
        >
          <div style={{ textAlign: 'left' }}>
            <Button
              type=""
              onClick={() => {
                this.setState({ tVisible: true, eVisible: false });
              }}
              style={{ marginRight: 30 }}
            >
              {'切换到跑分系统'}
            </Button>
            <Button
              type=""
              onClick={() => {
                this.setState({ kVisible: true, eVisible: false });
              }}
            >
              {'切换到k线系统'}
            </Button>
          </div>
          <br />
          <KlineEchartsNewTwo symbol={codes} mainId="NewTwoEcharts" />
        </Modal>
      </PageHeaderWrapper>
    );
  }

  componentDidMount() {
    const { dispatch } = this.props;

    /* 导入列表数据 */
    dispatch({
      type: 'fu/GetFundTwoStockPosition',
      payload: { currentDataSource: this.state.currentDataSource },
      callback: res => {
        this.setState({
          currentDataSource: res.list,
        });
      },
    });

    window.reloadData = setInterval(() => {
      const { dispatch } = this.props;
      /* 导入列表数据 */
      dispatch({
        type: 'fu/GetFundTwoStockPosition',
        payload: { currentDataSource: this.state.currentDataSource },
        callback: res => {
          if (res.code === 1) {
            message.success('刷新成功');
          } else {
            message.error('刷新失败');
          }
        },
      });
    }, 29000);
  }

  componentWillUnmount() {
    window.clearInterval(window.reloadData);
  }
}

export default NewTwoPosition;
